/* function TreeNode(x) {
    this.val = x;
    this.left = null;
    this.right = null;
} */
function Convert(pRootOfTree)
{
    // write code here
    if(pRootOfTree === null) return null
    var head = null
    var tail = null
    function convert(root){
      if(root === null) return
      convert(root.left)
      if(tail === null){
        head = root
      }else{
        tail.right = root
      }
      root.left = tail // 头结点的左指针指向的是null
      tail = root // 当前节点变成尾结点
      convert(root.right)
    }
    convert(pRootOfTree)
    return head
}
module.exports = {
    Convert : Convert
};